<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@ include file="/common/taglibs.jsp" %>	
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
label{
	width:150px;
}
</style>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- css js-->
<title>字典类型新增</title> 
</head>
<body>
 <div class="easyui-panel" border=false style="padding: 10px 20px;">
			<form id="formId" method="post" action="${ctx}/BscDicCode/saveType"
				data-options="novalidate:false">
					   <input type="hidden" name="typeId" value="${vo.typeId}" />	
					   <input type="hidden" name="oldtypeCode" value="${vo.typeCode}" />	
		 <table>
		 <tr>
		 <td>类型编码：</td>
		 <td> <input type="text" name="typeCode" id="typeCode" size="30" maxlength="50" class="easyui-textbox" 
					data-options="required:true,width:'120px'" value="${vo.typeCode}" />
					</td>
		</tr>
		 <tr>
		 <td>名称：</td>
		 <td><input type="text" name="typeName" size="30" maxlength="50" class="easyui-textbox" 
					data-options="required:true,width:'120px'" value="${vo.typeName}" /></td>
					</tr>
		 <tr>
		 
		 <td>创建人：</td>
		 <td><input type="text" name="typeCreater" size="30" maxlength="50" class="easyui-textbox" 
					data-options="required:true,width:'120px'" value="${vo.typeCreater}" /></td>
					</tr>
		 <tr>
		 <td>描述：</td>
		 <td><input type="text" name="typeMemo" size="30" maxlength="50" class="easyui-textbox" 
					data-options="width:'120px'" value="${vo.typeMemo}" /></td>
					</tr>
					
						<tr>
     			<td colspan="2" align="center" style="padding-top: 10px;">
	     			<a href="javascript:void(0)" class="easyui-linkbutton"
						iconCls="icon-remove" onclick="baseReset('formId')">重置</a> 
					<a href="javascript:void(0)" class="easyui-linkbutton"
						iconCls="icon-save" onclick="submitForm('formId','typedg','win')">提交</a> 
					<a href="javascript:void(0)" class="easyui-linkbutton"
						iconCls="icon-cancel" onclick="clearForm('win')">取消</a>
     			</td>
     		</tr>
		 </table>
		 </form>
</div>


<script type="text/javascript">
	var flag;
		function checktype()
		{
			var tcode=$("#typeCode").val();
			$.ajax({
				url : "${ctx}/BscDicCode/checkTypeCode",
				data : {
					typeCode:tcode
					},
				dataType : "json",
				type : "POST",
				async : false,
				success : function(data) {
					if(data.success==false)
					{
						alert(data.message);
						flag= false;
					}
					if(data.success==true)
					{
						flag= true;
					}
				},
				error : function() {
					alert("系统繁忙，请稍后再试");
				}
			})
		}
function submitForm(fid, gid, wid) {
	$('#' + fid).form('submit', {
		onSubmit : function() {
		flag= $(this).form('enableValidation').form('validate');
		if(flag==true)
		{
			checktype();
			if(flag==false)
			{
				return false;
			}
		}
		
		},
		success : function(data) {
			var data = eval('(' + data + ')');
			if (data) {
				if (data.success==true) {
					showMsg('提示', data.message);
					if (gid && gid != '') {
						$('#' + gid).datagrid({});
						$('#dg').datagrid({});
					}
					if (wid && wid != '') {
						$('#' + wid).window('close');
					}
				} else {
					showMsg('提示', data.message);
				}
			} else {
				showMsg('提示', '操作失败！');
			}
		}
	});
}
</script>

</body>
</html>